package com.lkm.app_ui.m.Imple.fun;

import com.lkm.app_ui.MyApplication;
import com.lkm.app_ui.RunTimeData;
import com.lkm.app_ui.m.fun.DelegatePayTask;
import com.lkm.frame.task.ProgressDataImpl;
import com.lkm.frame.task2.TaskAdapter;
import com.lkm.javatool.NumberHelp;
import com.lkm.market2_0.entity.ResponEntity;
import com.lkm.market2_0.netapi.Api;
import com.lkm.market2_0.task.DefaultTaskExecutor;

import java.util.HashMap;
import java.util.Map;



public class PayCodeTask extends TaskAdapter<DelegatePayTask.DelegatePayTaskP, Void, ResponEntity<Void>>  {

    public PayCodeTask() {
        super(new DefaultTaskExecutor(true), PayCodeTask.class.getName(), MyApplication.getInstance().getTaskManager2());
    }


    @Override
    public void doExecuting(DelegatePayTask.DelegatePayTaskP param) {
        super.doExecuting(param);

        mTaskExecutor.executor(new Runnable() {
            @Override
            public void run() {
                ResponEntity<Map<String, String>> re = null;
                try {
                    re = ResponEntity.fromJson(
                            Api.delegatePay(RunTimeData.steelyardExtData.payOnlineInfo.payUrl, param.orderEntity.steelyardMac, "" + RunTimeData.steelyardInfo.getOrg(), param.orderEntity,param.payCode, param.payType, PayCodeTask.this)
                            , new com.google.gson.reflect.TypeToken<HashMap<String, String>>() {
                            }.getType(), "");
                } catch (Exception e) {
                    re = new ResponEntity().fail("api数据解析失败");
                }
                ResponEntity<Void> ree = new ResponEntity(re);
                complete(ree);

            }
        });


    }


}
